import logging


class LoggerHandler(logging.Logger):

    def __init__(self,
                 name="root",
                 lever="DEBUG",
                 file=None,
                 fmt="%(asctime)s - %(filename)s - %(lineno)d - %(name)s - %(levelname)s - %(message)s"
                 ):
        super().__init__(name)
        self.setLevel(lever)

        fatter = logging.Formatter(fmt)

        if file:
            file_handler = logging.FileHandler(file)
            file_handler.setLevel(lever)
            file_handler.setFormatter(fatter)
            self.addHandler(file_handler)
        str_handler = logging.StreamHandler()
        str_handler.setLevel(lever)
        str_handler.setFormatter(fatter)
        self.addHandler(str_handler)
